package com.aistar.mapper;

import com.aistar.model.entity.Company;
import com.aistar.model.entity.Project;
import com.aistar.model.entity.ResumeView;
import com.aistar.model.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * @ClassName: UserMapper
 * @author: LiuWenXiu
 * @date: 2021/10/8 8:33
 * @Description: TODO...
 */


import java.util.List;

@ResponseBody
public interface UserMapper {

    @Select("select * from user where phone = #{phone}")
    User findByPhone(String phone);

    @Select("select * from user where id = #{id}")
    User findById(Integer Id);

    @Select("select * from user")
    List<User> findAll();


    User findByEmail(String email);


    // 根据用户名获取密码
    @Select("select password from user where username = #{username}")
    String findPwdByUsername(String username);

    // 根据用户名获取User对象
    @Select("select * from user where username = #{username}")
    User findUserByUsername(String username);

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into user(username,phone,password,user_type,email) values(#{username},#{phone},#{password},#{userType},#{email})")
    Integer insertByEmail(User user);

    @Delete("delete from user where user_id = #{userId}")
    Integer deleteUser(Integer userId);

    @Update("update user set password = #{password} where id = #{id}")
    Integer updateByid(User user);

    @Insert("insert into user(email,password) values(#{email},#{password})")
    Integer insterUser(User user);


}